package com.atguigu.gulimall.product.feign;

import com.atguigu.gulimall.common.to.SkuReductionTo;
import com.atguigu.gulimall.common.to.SpuBoundTo;
import com.atguigu.gulimall.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @program: gulimall
 * @author: yangshen
 * @description:
 * @create: 2020-07-10 18:07
 **/

@FeignClient("gulimall-coupon")
public interface CouponFeignService {

    /**
     * 调用过程详解
     * 1.CouponFeignService.saveSpuBounds(spuBoundTo);
     *      1)、@RequestBody将参数对象转化为json
     *      2)、在注册中心找到gulimall-coupon服务，给该服务发送/coupon/spubounds/save路径请求，将第一步转的json放到请求体的位置发送请求
     *      3）、远程被调用服务收到请求，请求体里有json数据
     *          （@RequestBody SpuBoundsEntity spuBounds）将请求体里的json转为 SpuBoundsEntity实体
     * 2.只要json数据模型是兼容的(字段名一样)，双方服务无需使用一个TO

     保存spu的积分信息，远程调用 gulimall_sms -> sms_spu_bounds
     * @param spuBoundTo spu积分传递参数实体To
     * @return
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);

    /**
     * sku的优惠满减信息，gulimall_sms -> sms_sku_ladder(打折) \ sms_sku_full_reduction(满减表) \ sms_member_price (会员价格表)
     * @param skuReductionTo spu的打折、满减、会员价格的传递实体To
     * @return
     */
    @PostMapping("/coupon/skufullreduction/saveInfo")
    R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
